﻿
CREATE PROCEDURE [dbo].[proc_Notice_GetList_CompanyTop]
	(
	@UserName nvarchar(50)
	)
AS
	Begin
		Declare @CompanyId int
		Set @CompanyId = (select Companyid from aspnet_Users where username=@UserName)
		select * from (
		Select
			top 5
			N.Id,
			N.NId,
			N.Fid,
			(select title from notice_category where id=N.fid) as category,
			N.Title,
			N.Content,
			N.UpName,
			N.IsAll,
			N.IsDing,
			N.CreateTime,
			N.UpTime 
		--From Notice N Where N.CompanyId=@CompanyId Order By N.IsDing DESC,UpTime DESC
		From Notice N Where 
		(N.CompanyId=@CompanyId OR N.CompanyIdList LIKE '%{' + CONVERT(VARCHAR(5),@CompanyId) + '}%') 
		Order By UpTime DESC) as a
		order by IsDing DESC
		
	End